package com.jming.jike.dto.backend;

import com.jming.jike.common.ValidatorGroup.Insert;
import com.jming.jike.common.ValidatorGroup.Update;
import com.jming.jike.dto.BaseDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2022/04/24
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class EmployeeDTO extends BaseDTO {


    @ApiModelProperty("id")
    @NotNull(message = "员工id不能为空", groups = {Update.class})
    @Min(value = 1, message = "员工id最小为{value}", groups = {Update.class})
    private Long id;

    @ApiModelProperty("姓名")
    @NotBlank(message = "姓名不能为空", groups = {Insert.class, Update.class})
    @Length(max = 10, message = "姓名不能超过{max}个字符", groups = {Insert.class, Update.class})
    private String name;

    @ApiModelProperty("用户名")
    @NotBlank(message = "用户名不能为空", groups = {Insert.class, Update.class})
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]{2,19}$", message = "用户名格式不正确 只能是数字、字母或下滑线, 且不能以_开头", groups = {Insert.class, Update.class})
    @Length(min = 3, max = 20, message = "长度在{min}-{max}个字符", groups = {Insert.class, Update.class})
    private String userName;

    @ApiModelProperty("手机号")
    @NotBlank(message = "手机号不能为空", groups = {Insert.class, Update.class})
    @Pattern(regexp = "[0-9-()（）]{7,18}", message = "手机号格式不正确", groups = {Insert.class, Update.class})
    private String phone;

    @ApiModelProperty("性别 1:男 2:女")
    @NotNull(message = "性别不能为空", groups = {Insert.class, Update.class})
    private Integer sex;

    @ApiModelProperty("身份证号")
    @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)", message = "身份证号码格式不正确", groups = {Insert.class, Update.class})
    private String idNumber;

}
